<?php 
//Luu giu trang thai loc theo loai ho so
$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
if(isset($_REQUEST['hdn_recordtype_filter'])){
	$v_recordtype_filter = $_REQUEST['hdn_recordtype_filter'];
} 
$v_record_id_filter ='';
if(isset($_REQUEST['hdn_record_id_list'])){
	$v_record_id_filter = $_REQUEST['hdn_record_id_list'];
}
$v_arrs_record_id=explode(",",$v_record_id_filter);

$v_list_xml_tag = "";
if(isset($_REQUEST['hdn_list_xml_tag'])){
	$v_list_xml_tag = $_REQUEST['hdn_list_xml_tag'];
}

$v_list_xml_value = "";
if(isset($_REQUEST['hdn_list_xml_value'])){
	$v_list_xml_value = $_REQUEST['hdn_list_xml_value'];
}

$v_date_update="";
if(isset($_REQUEST['txt_work_date1'])){
	$v_date_update = $_REQUEST['txt_work_date1'];
}

$v_received_date = "";
if(isset($_REQUEST['txt_received_date']))
{
	$v_received_date = $_REQUEST['txt_received_date'];
}
if(isset($_REQUEST['hdn_recordtype_filter']))
{
	$v_fk_recordtype = $_REQUEST['hdn_recordtype_filter'];
}

$v_status_work = "";
if(isset($_REQUEST['hdn_work']))
{
	$v_status_work = $_REQUEST['hdn_work'];
}

$strXML = '<?xml version="1.0" encoding="UTF-8"?><root><data_list>';
for ($i=0;$i<_list_get_len($v_list_xml_tag,_CONST_SUB_LIST_DELIMITOR);$i++){
	$strXML = $strXML ."<"._list_get_at($v_list_xml_tag,$i,_CONST_SUB_LIST_DELIMITOR).">";
	$strXML = $strXML .trim(_replace_XML_bad_char(_list_get_at($v_list_xml_value,$i,_CONST_SUB_LIST_DELIMITOR)));
	$strXML = $strXML ."</"._list_get_at($v_list_xml_tag,$i,_CONST_SUB_LIST_DELIMITOR).">";
}
$strXML = $strXML . "</data_list></root>";
$strXML = str_replace("'","",$strXML);
$v_record_id = 0;
if(isset($_REQUEST['hdn_record_id'])){
	$v_record_id = intval($_REQUEST['hdn_record_id']);
}
$v_status = $arr_record_status[0][0];
$v_recordtype = $_SESSION['onegate_current_recordtype'];
$v_receiver = $_SESSION['staff_id'];

if(_is_sqlserver()){
	$license_xml_data_id = _save_XML_to_database('T_TEMP_FILE', 'PK_TEMP_FILE', 'C_TEXT', $strXML);
	
	for($i=0;$i<sizeof($v_arrs_record_id);$i++){
		$v_record_id_filter=$v_arrs_record_id[$i];
		
		$sql='Exec Onegate_RecordStatusDetailUpdate_Dispute ';
		$sql = $sql . " '". $v_record_id_filter . "',";
		$sql = $sql . "'" .$v_status_work."',";
		$sql = $sql . "'" . _ddmmyyyy_to_yyyymmdd($v_date_update)."'";
		$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
		$rs = $ado_conn->GetRow($sql); 
		$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
	
	}
}
sleep(0);
if (!is_null($v_error) && $v_error<>""){?>
	<script>
		alert("<?php echo $v_error; ?>");
		if (_MODAL_DIALOG_MODE==1){
			window.location = "<?php echo $v_goto_url; ?>";
		}else{
			window.history.back();
		}	
	</script><?php
	exit;
}
?>
<form action="index.php" method="post" name="f_back">
	<input type="hidden" name="fuseaction" value="DISPLAY_ALL_RECORD_FOR_DISPUTE">
	<input type="hidden" name="hdn_record_id" value="<?php echo $v_record_id;?>">
	<input type="hidden" name="hdn_recordtype_filter" value="<?php echo $v_recordtype_filter; ?>">
</form>
<Script language="javascript">
	document.forms(0).submit();
</Script>